package com.demo.lottery;

import com.demo.common.model.Staff;
import com.jfinal.plugin.activerecord.Db;

import java.util.List;

/**
 * @author caizhongjie
 * @date 2018/1/3 下午1:29
 */
public class LotteryService extends BaseService<Staff>{
    public static final Staff dao = new Staff().dao();

    public boolean isExistLuckyNumber(String luckyNumber){
        return Staff.me.findFirst("select id from staff where lucky_number = ?",luckyNumber) != null;
    }

    public boolean isExistStaff(String staffName,String phone){
        return Staff.me.findFirst("select id from staff where staff_name=? and phone = ?",staffName,phone) != null;
    }
    public boolean register(){
        return Staff.me.save();
    }
    public Staff getLuckyNumber(String staffName,String phone){
        return Staff.me.findFirst("select * from staff where staff_name=? and phone = ?",staffName,phone);
    }
    public List<String> getLuckyNumberList(){
        return Db.query("select lucky_number from staff where is_lucky = 0");
    }
    public int update(String luckyNumber){
        return Db.update("update staff set is_lucky = 1 where lucky_number = ?",luckyNumber);
    }
}
